package frontend.model.admin;

import backend.model.admin.WorkDetail;
import backend.model.admin.Workplace;
import frontend.model.base.UIModel;

public class WorkDetailUIModel implements UIModel<WorkDetail> {

    private Workplace workplace;
    private String description;
    private boolean isActive;

    private WorkDetail workDetail;

    public WorkDetailUIModel() {
        workDetail = new WorkDetail();
        isActive = true;
    }

    public WorkDetailUIModel(WorkDetail workDetail) {
        this.workDetail = workDetail;
        populateFieldsFromDBModel();
    }

    @Override
    public void populateFieldsFromDBModel() {
        workplace = workDetail.getWorkplace();
        description = workDetail.getDescription();
        isActive = workDetail.getIsActive();
    }

    @Override
    public void populateDBModelFromFields() {
        workDetail.setDescription(description);
        workDetail.setWorkplace(workplace);
        workDetail.setIsActive(isActive);
    }

    public Workplace getWorkplace() {
        return workplace;
    }

    public String getDescription() {
        return description;
    }

    @Override
    public WorkDetail getDBModel() {
        return workDetail;
    }
}
